package com.ruoyi.huoyun.message.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.huoyun.message.domain.ToConsignorEvaluate;
import com.ruoyi.huoyun.message.service.IToConsignorEvaluateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 对货主的评价Controller
 *
 * @author mj
 * @date 2021-11-29
 */
@RestController
@RequestMapping("/message/toConsignor")
public class ToConsignorEvaluateController extends BaseController
{
    @Autowired
    private IToConsignorEvaluateService toConsignorEvaluateService;

    /**
     * 查询对货主的评价列表
     */
    @PreAuthorize("@ss.hasPermi('message:toConsignor:list')")
    @GetMapping("/list")
    public TableDataInfo list(ToConsignorEvaluate toConsignorEvaluate)
    {
        startPage();
        List<ToConsignorEvaluate> list = toConsignorEvaluateService.selectToConsignorEvaluateList(toConsignorEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出对货主的评价列表
     */
    @PreAuthorize("@ss.hasPermi('message:toConsignor:export')")
    @Log(title = "对货主的评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ToConsignorEvaluate toConsignorEvaluate)
    {
        List<ToConsignorEvaluate> list = toConsignorEvaluateService.selectToConsignorEvaluateList(toConsignorEvaluate);
        ExcelUtil<ToConsignorEvaluate> util = new ExcelUtil<ToConsignorEvaluate>(ToConsignorEvaluate.class);
        util.exportExcel(response, list, "对货主的评价数据");
    }

    /**
     * 获取对货主的评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('message:toConsignor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(toConsignorEvaluateService.selectToConsignorEvaluateById(id));
    }

    /**
     * 新增对货主的评价
     */
    @PreAuthorize("@ss.hasPermi('message:toConsignor:add')")
    @Log(title = "对货主的评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ToConsignorEvaluate toConsignorEvaluate)
    {
        return toAjax(toConsignorEvaluateService.insertToConsignorEvaluate(toConsignorEvaluate));
    }

    /**
     * 修改对货主的评价
     */
    @PreAuthorize("@ss.hasPermi('message:toConsignor:edit')")
    @Log(title = "对货主的评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ToConsignorEvaluate toConsignorEvaluate)
    {
        return toAjax(toConsignorEvaluateService.updateToConsignorEvaluate(toConsignorEvaluate));
    }

    /**
     * 删除对货主的评价
     */
    @PreAuthorize("@ss.hasPermi('message:toConsignor:remove')")
    @Log(title = "对货主的评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(toConsignorEvaluateService.deleteToConsignorEvaluateByIds(ids));
    }
}
